<template>
  <el-select
    v-model="provinceCode"
    filterable
    clearable
    class="w-100"
    @change="provinceChange"
    placeholder="请选择省份"
  >
    <el-option
      v-for="item in provinceList"
      :key="item.provinceCode"
      :label="item.provinceName"
      :value="item.provinceCode"
    >
    </el-option>
  </el-select>
</template>

<script>
import { getAllProvince } from '@/api/after-sale/common/common'
export default {
  props: {
    value: {
      default: '',
    },
  },
  data() {
    return {
      provinceCode: '',
      provinceList: [],
    }
  },
   watch: {
    value: function (newValue, oldValue) {
      this.provinceCode = newValue;
       this.$emit('input', newValue)
    },
  },
  methods: {
    provinceChange(value) {
      this.$emit('input', value)
    },
  },
  async mounted() {
    const { data } = await getAllProvince()
    this.provinceList = data;
    if(this.value){
      this.provinceList=this.value;
    }
  },
}
</script>